
const path = require('path');
const fs = require('fs');
const { start } = require('repl');

var utils = {

    /**
     * 获取目录下的所有文件
     * @param {*} dir 
     */
    walkDirFiles(dir) {
        let files = []
        this._walkDirFiles(dir, files)
        return files
    },

    _walkDirFiles(dir, files) {
        if (fs.existsSync(dir)) {
            fs.readdirSync(dir).forEach((file) => {
                var filePath = path.join(dir, file);
                var stat = fs.statSync(filePath);
                if (stat.isFile()) {
                    files.push(filePath)
                } else if (stat.isDirectory()) {
                    if (file != ".svn") {
                        this._walkDirFiles(filePath, files);
                    }
                }
            });
        } else {
            console.log("_walkDirFiles " + dir)
        }
    }


}
module.exports = utils;